#include <iostream>
using namespace std;

signed main()
{
    string s1,s2;
    cin>>s1>>s2;
    int mins = 0x3f3f3f,ans1,ans2;
    for(int i=0;i<s1.size();i++){
        if(s1[i]==s2[0]){
            int l=i,r=0;
            while(l<s1.size()&&r<s2.size()){
                if(s1[l]==s2[r]){
                    l++;r++;
                }
                else    l++;
            }
            if(r==s2.size()&&l-i<mins){
                ans1 = i;
                ans2 = l;
                mins = l-i;
            }
            if(r<s2.size())    break;
        }
    }
    for(int i=ans1;i<ans2;i++)    cout<<s1[i];
    return 0;
}
